/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.revivius.jbtorrent.entity;

import com.revivius.jbtorrent.util.HashUtil;
import java.util.List;

/**
 *
 * @author Revivius
 */
public class TorrentInfo {
    private long length;
    private String name;
    private long pieceLength;
    private List<byte[]> pieces;
    private List<FileInfo> files;
    private boolean privateFlag;
    private byte[] hash;

    /**
     * @return the length
     */
    public long getLength() {
        return length;
    }

    /**
     * @param length the length to set
     */
    public void setLength(long length) {
        this.length = length;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the pieceLength
     */
    public long getPieceLength() {
        return pieceLength;
    }

    /**
     * @param pieceLength the pieceLength to set
     */
    public void setPieceLength(long pieceLength) {
        this.pieceLength = pieceLength;
    }

    /**
     * @return the pieces
     */
    public List<byte[]> getPieces() {
        return pieces;
    }

    /**
     * @param pieces the pieces to set
     */
    public void setPieces(List<byte[]> pieces) {
        this.pieces = pieces;
    }

    /**
     * @return the files
     */
    public List<FileInfo> getFiles() {
        return files;
    }

    /**
     * @param files the files to set
     */
    public void setFiles(List<FileInfo> files) {
        this.files = files;
    }

    /**
     * @return the privateFlag
     */
    public boolean isPrivateFlag() {
        return privateFlag;
    }

    /**
     * @param privateFlag the privateFlag to set
     */
    public void setPrivateFlag(boolean privateFlag) {
        this.privateFlag = privateFlag;
    }

    /**
     *
     * @return
     */
    public byte[] getHash() {
        return hash;
    }

    /**
     *
     * @param hash
     */
    public void setHash(byte[] hash) {
        this.hash = hash;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Info[").append("\n");
        sb.append("\t").append("hash = ").append(HashUtil.toHex(hash)).append("\n");
        sb.append("\t").append("length = ").append(getLength()).append("\n");
        sb.append("\t").append("files = ").append(getFiles()).append("\n");
        sb.append("\t").append("name = ").append(getName()).append("\n");
        sb.append("\t").append("piece length = ").append(getPieceLength()).append("\n");
        sb.append("\t").append("pieces = ").append(getPieces()).append("\n");
        sb.append("\t").append("private = ").append(isPrivateFlag()).append("\n");
        sb.append("]");
        return sb.toString();
    }
    
}
